package base;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Enumeration;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class BaseServer
 */
public class BaseServer extends HttpServlet {
	private static final long serialVersionUID = 1L;

    /**
     * Default constructor. 
     */
    public BaseServer() {
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		
		// TODO Auto-generated method stub

		
		
		response.setCharacterEncoding("UTF-8");
		response.setContentType("application/json; charset=utf-8");
		String jsonStr = "{\"p\":\"56\",\"yr\":\"虫fsdfsadfdsfsdfsdfsdfsdfsdfsdafsdafsdfadsfsdafsfsf发的发生的范德萨发撒旦法师打发防守打法水电费阿斯顿发生双方都发送到撒反对双方都阿斯蒂芬阿斯蒂芬水电费防守打法防守打法水电费水电费双方都发送到子\",\"name\":\"fly\",\"type\":\"虫子\",\"name\":\"fly\",\"type\":\"虫子\",\"name\":\"fly\",\"type\":\"虫子\",\"name\":\"fly\",\"type\":\"虫子\",\"name\":\"fly\",\"type\":\"虫子\",\"age\":\"11\"}";
		PrintWriter out = null;
		try {
		    out = response.getWriter();
		    
		    Enumeration enu=request.getParameterNames();
		    while(enu.hasMoreElements()){
		    String paraName=(String)enu.nextElement();
		    System.out.println(paraName+": "+request.getParameter(paraName));
		    
//		    out.write(paraName+": "+request.getParameter(paraName));
		    }
		    out.write(jsonStr);
		    
		    
		} catch (IOException e) {
		    e.printStackTrace();
		} finally {
		    if (out != null) {
		        out.close();
		    }
		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
